<?php
	header('content-type:text/html;charset=utf-8');
	$username=isset($_GET['name'])?$_GET['name']:'';
	$pass=isset($_GET['pass'])?$_GET['pass']:'';
	$mysql=@mysql_connect('localhost','root','12345678');//@容错
	if(!$mysql){
		die('数据库链接错误'.mysql_error());
	}
	mysql_select_db('yintai');
	mysql_query('SET NAMES UTF8');
	if($username&&$pass){
		$insert='insert login values(null,"'.$username.'","'.$pass.'")';
		mysql_query($insert);
	}
	$query='select * from login';
	$result=mysql_query($query);
	$arr=array();
	
	
	for($i=0;$i<mysql_num_rows($result);$i++){
		$arr[$i]=mysql_fetch_array($result,MYSQL_NUM);
		
	}
	echo json_encode($arr);
	mysql_close($mysql);
	
	?>